
package jpamodel;

import java.io.Serializable;
import java.time.LocalDate;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Joseph
 */
@Entity
@Table(name = "PriceHistory")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PriceHistory.findAll", query = "SELECT p FROM PriceHistory p"),
    @NamedQuery(name = "PriceHistory.findByHistID", query = "SELECT p FROM PriceHistory p WHERE p.histID = :histID"),
    @NamedQuery(name = "PriceHistory.findByPrice", query = "SELECT p FROM PriceHistory p WHERE p.price = :price"),
    @NamedQuery(name = "PriceHistory.findByDateOfChange", query = "SELECT p FROM PriceHistory p WHERE p.dateOfChange = :dateOfChange")})
public class PriceHistory implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "hist_ID")
    private Integer histID;
    @Basic(optional = false)
    @Column(name = "price")
    private int price;
    @Column(name = "dateOfChange")
    @Temporal(TemporalType.TIMESTAMP)
    private LocalDate dateOfChange;
    @JoinColumn(name = "fk_item_ID", referencedColumnName = "item_ID")
    @ManyToOne(optional = false)
    private CommissionWare fkitemID;

    public PriceHistory() {
    }

    public PriceHistory(Integer histID) {
        this.histID = histID;
    }

    public PriceHistory(Integer histID, int price) {
        this.histID = histID;
        this.price = price;
    }

    public Integer getHistID() {
        return histID;
    }

    public void setHistID(Integer histID) {
        this.histID = histID;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public LocalDate getDateOfChange() {
        return dateOfChange;
    }

    public void setDateOfChange(LocalDate dateOfChange) {
        this.dateOfChange = dateOfChange;
    }

    public CommissionWare getFkitemID() {
        return fkitemID;
    }

    public void setFkitemID(CommissionWare fkitemID) {
        this.fkitemID = fkitemID;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (histID != null ? histID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PriceHistory)) {
            return false;
        }
        PriceHistory other = (PriceHistory) object;
        return !((this.histID == null && other.histID != null) || (this.histID != null && !this.histID.equals(other.histID)));
    }
    
}
